package conf2.ui;

import java.awt.Component;
import javax.swing.Icon;
import javax.swing.JOptionPane;

public class MessageBox {

    public static int yesNo(Component mainWindow, String message, String caption, Icon icon, boolean closeable) {
        
        String options[] = {"  Yes  ", "  No  "};
        int ans;
        do {
            ans = JOptionPane.showOptionDialog(mainWindow,
                    message, caption, JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    icon, options, options[0]);
        } while (ans == JOptionPane.CLOSED_OPTION && !closeable);
        return ans;
    }

    public static int ok(Component mainWindow, String message, String caption, Icon icon, boolean closeable) {
        String options[] = {"  OK  "};
        int ans;
        do {
            ans = JOptionPane.showOptionDialog(mainWindow,
                    message, caption, JOptionPane.OK_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    icon, options, options[0]);
        } while (ans == JOptionPane.CLOSED_OPTION && !closeable);
        return ans;
    }

    public static int cancel(Component mainWindow, String message, String caption, Icon icon, boolean closeable) {
        String options[] = {"Cancel"};
        int ans;
        do {
            ans = JOptionPane.showOptionDialog(mainWindow,
                    message, caption, JOptionPane.CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    icon, options, options[0]);
        } while (ans == JOptionPane.CLOSED_OPTION && !closeable);
        return ans;
    }
}
